package com.hutiao.snowhb.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hutiao.snowhb.dao.BaseDao;
import com.hutiao.snowhb.entities.MenuKey;
import com.hutiao.snowhb.wechat.vo.WxSendMsg;
import com.hutiao.snowhb.wechat.vo.WxSendTextMsg;

@Component
public class MenuService {

	@Autowired
	private BaseDao baseDao;
	
	public List<MenuKey> getAllKeys() {
		
		String sql = "select kid,`key`,msgType,text_content,news_title,news_description,news_picUrl,news_url,news_position, "
				+ "multi_mediaId,music_title,music_description,music_musicURL,music_HQMusicUrl,music_thumbMediaId,createTime,updateTime  "
				+ "from snow_menu_click order by `key`,news_position;";
		
		List<Map<String, Object>> tempList = this.baseDao.queryForList(sql);
		
		if (tempList == null || tempList.size() == 0) {
			return null;
		}
		
		List<MenuKey> keyList = new ArrayList<MenuKey>();
		for (Map<String, Object> temp : tempList) {
			
			MenuKey menuKey = new MenuKey();
			menuKey.setKey(temp.get("key").toString());

			// text image voice video music news subscribe unsubscribe
			String msgType = temp.get("msgType").toString();
			if (msgType.equals("text")) {
				String text = temp.get("text_content").toString();
				WxSendTextMsg msg = new WxSendTextMsg(new WxSendMsg("", "", "", msgType), text);
				menuKey.setMsg(msg);
			} else if (msgType.equals("news")) {
				
				
			} else if (msgType.equals("image")) {
				
			} else if (msgType.equals("voice")) {
				
			} else if (msgType.equals("video")) {
				
			} else if (msgType.equals("music")) {
				
			} else if (msgType.equals("subscribe")) {
				
			} else if (msgType.equals("unsubscribe")) {
				
			}
			
		}
		
		
		return null;
	}
	
	
} 
